import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.testng.annotations.Test;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class c3p0 {
    @Test
    public void c3p0() throws SQLException {
        ComboPooledDataSource hello = new ComboPooledDataSource("hello");
        long start=System.currentTimeMillis();
        for (int i = 0; i < 5000; i++) {
            Connection connection= hello.getConnection();
             connection.close();
        }
        long end=System.currentTimeMillis();
        System.out.println(end-start);
    }
    @Test
    public void de() throws Exception {
        Properties properties=new Properties();
        properties.load(new FileInputStream("src\\druid.properties"));
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        long start=System.currentTimeMillis();
        for (int i = 0; i < 5000; i++) {
            Connection connection= dataSource.getConnection();
            connection.close();
        }
        long end=System.currentTimeMillis();
        System.out.println(end-start);
    }
}
